import store from '@/store/index'
import Message from 'element-ui/packages/message'
import i18n from '@/i18n/i18n'
// 1
const msg_info=function(message = "info!",type="info",duration=2000,showClose=false) {
	Message({
		showClose,
		type,
		message,
		duration,
		center: 'center',
		customClass:'message',
		offset: store.state.fullHeight / 2,
	});
}
// 2
const msg_successOpera=function(duration=2000,showClose=false,message = i18n.t('messages.success_opera')){
	Message({
		type: 'success',
	    showClose,
	    message,
		duration,
	    center: 'center',
	    customClass:'message',
	    offset: store.state.fullHeight / 2,
	})
}
// 3
const msg_successCancel=function(duration=2000,showClose=false,message = i18n.t('messages.success_cancel')) {
	Message({
			type: 'success',
			showClose,
			message,
			duration,
			center: 'center',
			customClass:'message',
			offset: store.state.fullHeight / 2,
		})
	}
// 4
const  success_refresh=function(duration=2000,showClose=false,message = i18n.t('messages.success_refresh')) {
	Message({
		type: 'success',
		showClose,
		message,
		duration,
		center: 'center',
		customClass:'message',
		offset: store.state.fullHeight / 2,
	})
}
// 5
const msg_error=function(message = "error!",duration=2000,showClose=false) {
	Message({
		type: 'error',
		showClose,
		message,
		duration,
		center: 'center',
		customClass:'message',
		offset: store.state.fullHeight / 2,
	});
}
// 6
const msg_errorLatestOne=function(duration=2000,showClose=false,message = i18n.t('messages.error_latestOne')) {
	Message({
		type: 'error',
		showClose,
		message,
		duration,
		center: 'center',
		customClass:'message',
		offset: store.state.fullHeight / 2,
	})
}
// 7
const msg_errorMostOne=function(duration=2000,showClose=false,message = i18n.t('messages.error_mostOne')) {
	Message({
		showClose,
		type: 'error',
		message,
		duration,
		center: 'center',
		customClass:'message',
		offset: store.state.fullHeight / 2,
	});
}
// 8
const msg_errorOpera=function(duration=2000,showClose=false,message = i18n.t('messages.error_opera')) {
	Message({
		showClose,
		type: 'error',
		message,
		duration,
		center: 'center',
		customClass:'message',
		offset: store.state.fullHeight / 2,
	})
}
// 9
const  table_radio=function(val, refs) {
	if (val.length >= 2) {
		let arr = val.splice(0, val.length - 1);
		arr.forEach(row => {
			refs.toggleRowSelection(row)
		})
	}
}

export{
	// msg
	msg_info,
	msg_successOpera,
	msg_successCancel,
	msg_errorLatestOne,
	msg_error,
	success_refresh,
	msg_errorMostOne,
	msg_errorOpera,
	// table
	table_radio,
	
}